<?php


namespace app\api\model;

use think\Model;

/**
 * Admin 模型
 * Class Admin
 * @package app\admin\model
 */
class Admin extends Model
{
    /**
     * 开启自动写入时间戳
     * @var bool
     */
    protected $autoWriteTimestamp = true;

    /**
     * @var string 时间输出格式
     */
    protected $dateFormat = 'Y-m-d H:i:s';
    /**
     * @var string[] 数据写入时类型转换
     */
    protected $type = [
        'status' => 'integer',
        'login_time' => 'timestamp',
        'create_time' => 'timestamp',
        'update_time' => 'timestamp',
        'delete_time' => 'timestamp',
        'gender' => 'integer'
    ];

    protected function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
    }

    /**
     * Admin关联AdminRole
     * @return Admin|array|false|string|\think\model\relation\BelongsTo
     */
    public function group()
    {
        return $this->belongsTo('AdminRole', 'id', 'admin_id', [], 'LEFT')->setEagerlyType(0);
    }
}